﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.Api.Application.Command.Add;
using Traceability.App.Api.Application.Command.Get;
using Traceability.App.Api.DTO;
using Traceability.App.Domain;
using Traceability.App.ErrorCode;

namespace Traceability.App.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SlaughterController : ControllerBase
    {
        private readonly IMediator mediator;

        public SlaughterController(IMediator mediator) 
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 显示屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<SlaughterModel>> GetSlaughter([FromQuery]GetTuCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 设置屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public Task<ApiResult<int>> AddSlaughter(AddSlaughterCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 显示屠宰企业信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<SlaughterCompany>> GetTuCompany([FromQuery]GetTuCompanyCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 设置屠宰企业信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddSlaughterCompany(AddTuCompanyCommand request)
        {
            return mediator.Send(request);
        }

    }
}
